/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('mscopensubscription', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model CreateContactRequest {
  clientToken?: string(name='ClientToken', example='123e4567-e89b-12d3-a456-426655440000'),
  contactName?: string(name='ContactName', description='联系人名称

This parameter is required.', example='图灵'),
  email?: string(name='Email', description='联系人电子邮箱

This parameter is required.', example='turing@addr.cs'),
  locale?: string(name='Locale', example='zh-cn'),
  mobile?: string(name='Mobile', description='用户电话

This parameter is required.', example='13910772437'),
  position?: string(name='Position', description='职位

This parameter is required.', example='技术负责人'),
}

model CreateContactResponseBody = {
  code?: string(name='Code', example='200'),
  contactId?: long(name='ContactId', example='10086'),
  message?: string(name='Message', example='调用成功'),
  requestId?: string(name='RequestId', example='473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E'),
  success?: boolean(name='Success', example='true'),
}

model CreateContactResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CreateContactResponseBody(name='body'),
}

/**
 * @summary 创建联系人
 *
 * @param request CreateContactRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return CreateContactResponse
 */
async function createContactWithOptions(request: CreateContactRequest, runtime: Util.RuntimeOptions): CreateContactResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.clientToken)) {
    query['ClientToken'] = request.clientToken;
  }
  if (!Util.isUnset(request.locale)) {
    query['Locale'] = request.locale;
  }
  var body : map[string]any = {};
  if (!Util.isUnset(request.contactName)) {
    body['ContactName'] = request.contactName;
  }
  if (!Util.isUnset(request.email)) {
    body['Email'] = request.email;
  }
  if (!Util.isUnset(request.mobile)) {
    body['Mobile'] = request.mobile;
  }
  if (!Util.isUnset(request.position)) {
    body['Position'] = request.position;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'CreateContact',
    version = '2021-07-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 创建联系人
 *
 * @param request CreateContactRequest
 * @return CreateContactResponse
 */
async function createContact(request: CreateContactRequest): CreateContactResponse {
  var runtime = new Util.RuntimeOptions{};
  return createContactWithOptions(request, runtime);
}

model CreateSubscriptionItemRequest {
  itemName?: string(name='ItemName', description='This parameter is required.'),
  locale?: string(name='Locale', example='zh-cn'),
}

model CreateSubscriptionItemResponseBody = {
  code?: string(name='Code', example='200'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId', description='Id of the request', example='FF1EFA25-9DB3-13E4-9643-5D3AD301C1D'),
  subscriptionItem?: {
    channel?: string(name='Channel', description='属于通道', example='tts'),
    contactIds?: [ long ](name='ContactIds', description='订阅联系人'),
    description?: string(name='Description', description='订阅项描述'),
    emailStatus?: int32(name='EmailStatus', description='邮件订阅情况', example='1'),
    itemId?: int32(name='ItemId', description='代表资源一级ID的资源属性字段', example='32'),
    itemName?: string(name='ItemName', description='订阅项名称'),
    pmsgStatus?: int32(name='PmsgStatus', description='站内信订阅情况', example='1'),
    smsStatus?: int32(name='SmsStatus', description='短信订阅情况', example='1'),
    ttsStatus?: int32(name='TtsStatus', description='语音短信订阅情况', example='-2'),
    webhookIds?: [ long ](name='WebhookIds', description='订阅webhooks'),
    webhookStatus?: int32(name='WebhookStatus', description='回调订阅情况', example='1'),
  }(name='SubscriptionItem', description='result'),
  success?: boolean(name='Success', example='true'),
}

model CreateSubscriptionItemResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CreateSubscriptionItemResponseBody(name='body'),
}

/**
 * @summary 伪创建接口，根据itemName查询
 *
 * @param request CreateSubscriptionItemRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return CreateSubscriptionItemResponse
 */
async function createSubscriptionItemWithOptions(request: CreateSubscriptionItemRequest, runtime: Util.RuntimeOptions): CreateSubscriptionItemResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.locale)) {
    query['Locale'] = request.locale;
  }
  var body : map[string]any = {};
  if (!Util.isUnset(request.itemName)) {
    body['ItemName'] = request.itemName;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'CreateSubscriptionItem',
    version = '2021-07-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 伪创建接口，根据itemName查询
 *
 * @param request CreateSubscriptionItemRequest
 * @return CreateSubscriptionItemResponse
 */
async function createSubscriptionItem(request: CreateSubscriptionItemRequest): CreateSubscriptionItemResponse {
  var runtime = new Util.RuntimeOptions{};
  return createSubscriptionItemWithOptions(request, runtime);
}

model CreateWebhookRequest {
  clientToken?: string(name='ClientToken', example='abc-def'),
  locale?: string(name='Locale', example='zh-cn'),
  serverUrl?: string(name='ServerUrl', description='回调地址

This parameter is required.', example='https://oapi.dingtalk.com/robot/send?access_token='),
  webhookName?: string(name='WebhookName', description='名称

This parameter is required.'),
}

model CreateWebhookResponseBody = {
  code?: string(name='Code', example='200'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId', description='Id of the request', example='FF1EFA25-9DB3-13E4-9643-5D3AD301C1D'),
  success?: boolean(name='Success', example='true'),
  webhookId?: long(name='WebhookId', example='10086'),
}

model CreateWebhookResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CreateWebhookResponseBody(name='body'),
}

/**
 * @summary 创建钉钉群机器人
 *
 * @param request CreateWebhookRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return CreateWebhookResponse
 */
async function createWebhookWithOptions(request: CreateWebhookRequest, runtime: Util.RuntimeOptions): CreateWebhookResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.clientToken)) {
    query['ClientToken'] = request.clientToken;
  }
  if (!Util.isUnset(request.locale)) {
    query['Locale'] = request.locale;
  }
  var body : map[string]any = {};
  if (!Util.isUnset(request.serverUrl)) {
    body['ServerUrl'] = request.serverUrl;
  }
  if (!Util.isUnset(request.webhookName)) {
    body['WebhookName'] = request.webhookName;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'CreateWebhook',
    version = '2021-07-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 创建钉钉群机器人
 *
 * @param request CreateWebhookRequest
 * @return CreateWebhookResponse
 */
async function createWebhook(request: CreateWebhookRequest): CreateWebhookResponse {
  var runtime = new Util.RuntimeOptions{};
  return createWebhookWithOptions(request, runtime);
}

model DeleteContactRequest {
  contactId?: long(name='ContactId', description='This parameter is required.', example='10086'),
  locale?: string(name='Locale', example='zh-cn'),
}

model DeleteContactResponseBody = {
  code?: string(name='Code', example='200'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId', description='Id of the request', example='FF1EFA25-9DB3-13E4-9643-5D3AD301C1D'),
  result?: boolean(name='Result', example='true'),
  success?: boolean(name='Success', example='true'),
}

model DeleteContactResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DeleteContactResponseBody(name='body'),
}

/**
 * @summary 删除联系人
 *
 * @param request DeleteContactRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DeleteContactResponse
 */
async function deleteContactWithOptions(request: DeleteContactRequest, runtime: Util.RuntimeOptions): DeleteContactResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.locale)) {
    query['Locale'] = request.locale;
  }
  var body : map[string]any = {};
  if (!Util.isUnset(request.contactId)) {
    body['ContactId'] = request.contactId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'DeleteContact',
    version = '2021-07-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 删除联系人
 *
 * @param request DeleteContactRequest
 * @return DeleteContactResponse
 */
async function deleteContact(request: DeleteContactRequest): DeleteContactResponse {
  var runtime = new Util.RuntimeOptions{};
  return deleteContactWithOptions(request, runtime);
}

model DeleteWebhookRequest {
  locale?: string(name='Locale', example='zh-cn'),
  webhookId?: long(name='WebhookId', description='This parameter is required.', example='10086'),
}

model DeleteWebhookResponseBody = {
  code?: string(name='Code', example='200'),
  message?: string(name='Message', example='true'),
  requestId?: string(name='RequestId', description='Id of the request', example='1629429213'),
  result?: boolean(name='Result', example='true'),
  success?: boolean(name='Success', example='true'),
}

model DeleteWebhookResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DeleteWebhookResponseBody(name='body'),
}

/**
 * @summary 删除钉钉群机器人
 *
 * @param request DeleteWebhookRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DeleteWebhookResponse
 */
async function deleteWebhookWithOptions(request: DeleteWebhookRequest, runtime: Util.RuntimeOptions): DeleteWebhookResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.locale)) {
    query['Locale'] = request.locale;
  }
  var body : map[string]any = {};
  if (!Util.isUnset(request.webhookId)) {
    body['WebhookId'] = request.webhookId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'DeleteWebhook',
    version = '2021-07-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 删除钉钉群机器人
 *
 * @param request DeleteWebhookRequest
 * @return DeleteWebhookResponse
 */
async function deleteWebhook(request: DeleteWebhookRequest): DeleteWebhookResponse {
  var runtime = new Util.RuntimeOptions{};
  return deleteWebhookWithOptions(request, runtime);
}

model GetContactRequest {
  contactId?: long(name='ContactId', description='This parameter is required.', example='10086'),
  locale?: string(name='Locale', example='zh-cn'),
}

model GetContactResponseBody = {
  code?: string(name='Code', example='200'),
  contact?: {
    accountUid?: long(name='AccountUid', description='账号UID', example='12306'),
    contactId?: long(name='ContactId', description='代表资源一级ID的资源属性字段', example='10086'),
    contactName?: string(name='ContactName', description='联系人名称', example='turing'),
    email?: string(name='Email', description='联系人电子邮箱', example='turing@addr.cs'),
    isAccount?: boolean(name='IsAccount', description='是否是账号本身', example='false'),
    isObsolete?: boolean(name='IsObsolete', description='是否过期', example='false'),
    isVerifiedEmail?: boolean(name='IsVerifiedEmail', description='电子邮箱是否验证', example='true'),
    isVerifiedMobile?: boolean(name='IsVerifiedMobile', description='电话是否验证', example='false'),
    lastEmailVerificationTimeStamp?: long(name='LastEmailVerificationTimeStamp', description='上封验证邮件发送时间', example='1629429213'),
    lastMobileVerificationTimeStamp?: long(name='LastMobileVerificationTimeStamp', description='上条验证短信发送时间', example='1629429213'),
    mobile?: string(name='Mobile', description='用户电话', example='1399999999'),
    position?: string(name='Position', description='职位'),
  }(name='Contact'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId', description='requestId', example='FF1EFA25-9DB3-13E4-9643-5D3AD301C1D'),
  success?: boolean(name='Success', example='true'),
}

model GetContactResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetContactResponseBody(name='body'),
}

/**
 * @summary 获得某联系人
 *
 * @param request GetContactRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetContactResponse
 */
async function getContactWithOptions(request: GetContactRequest, runtime: Util.RuntimeOptions): GetContactResponse {
  Util.validateModel(request);
  var query = OpenApiUtil.query(Util.toMap(request));
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetContact',
    version = '2021-07-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'GET',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 获得某联系人
 *
 * @param request GetContactRequest
 * @return GetContactResponse
 */
async function getContact(request: GetContactRequest): GetContactResponse {
  var runtime = new Util.RuntimeOptions{};
  return getContactWithOptions(request, runtime);
}

model GetSubscriptionItemRequest {
  itemId?: int32(name='ItemId', description='This parameter is required.', example='32'),
  locale?: string(name='Locale', example='zh-cn'),
}

model GetSubscriptionItemResponseBody = {
  code?: string(name='Code', example='200'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId', description='Id of the request', example='FF1EFA25-9DB3-13E4-9643-5D3AD301C1D'),
  subscriptionItem?: {
    channel?: string(name='Channel', description='属于通道', example='tts'),
    contactIds?: [ long ](name='ContactIds', description='订阅联系人'),
    description?: string(name='Description', description='订阅项描述'),
    emailStatus?: int32(name='EmailStatus', description='邮件订阅情况', example='1'),
    itemId?: int32(name='ItemId', description='代表资源一级ID的资源属性字段', example='10086'),
    itemName?: string(name='ItemName', description='订阅项名称'),
    pmsgStatus?: int32(name='PmsgStatus', description='站内信订阅情况', example='1'),
    smsStatus?: int32(name='SmsStatus', description='短信订阅情况', example='1'),
    ttsStatus?: int32(name='TtsStatus', description='语音短信订阅情况', example='1'),
    webhookIds?: [ long ](name='WebhookIds', description='订阅webhooks'),
    webhookStatus?: int32(name='WebhookStatus', description='回调订阅情况', example='1'),
  }(name='SubscriptionItem', description='result'),
  success?: boolean(name='Success', example='true'),
}

model GetSubscriptionItemResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetSubscriptionItemResponseBody(name='body'),
}

/**
 * @summary 获得用户订阅项
 *
 * @param request GetSubscriptionItemRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetSubscriptionItemResponse
 */
async function getSubscriptionItemWithOptions(request: GetSubscriptionItemRequest, runtime: Util.RuntimeOptions): GetSubscriptionItemResponse {
  Util.validateModel(request);
  var query = OpenApiUtil.query(Util.toMap(request));
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetSubscriptionItem',
    version = '2021-07-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'GET',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 获得用户订阅项
 *
 * @param request GetSubscriptionItemRequest
 * @return GetSubscriptionItemResponse
 */
async function getSubscriptionItem(request: GetSubscriptionItemRequest): GetSubscriptionItemResponse {
  var runtime = new Util.RuntimeOptions{};
  return getSubscriptionItemWithOptions(request, runtime);
}

model GetSubscriptionItemDetailRequest {
  itemId?: int32(name='ItemId', example='32'),
  locale?: string(name='Locale', example='zh-cn'),
}

model GetSubscriptionItemDetailResponseBody = {
  code?: string(name='Code', example='200'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId', description='Id of the request', example='FF1EFA25-9DB3-13E4-9643-5D3AD301C1D'),
  subscriptionItemDetail?: {
    channel?: string(name='Channel', description='属于通道', example='tts'),
    contacts?: [ 
      {
        accountUID?: long(name='AccountUID', description='账号UID', example='12306'),
        contactId?: long(name='ContactId', description='代表资源一级ID的资源属性字段', example='10086'),
        email?: string(name='Email', description='联系人电子邮箱', example='turing@addr.cs'),
        isAccount?: boolean(name='IsAccount', description='是否是账号本身', example='false'),
        isObsolete?: boolean(name='IsObsolete', description='是否过期', example='false'),
        isVerifiedEmail?: boolean(name='IsVerifiedEmail', description='电子邮箱是否验证', example='true'),
        isVerifiedMobile?: boolean(name='IsVerifiedMobile', description='电话是否验证', example='false'),
        lastEmailVerificationTimeStamp?: long(name='LastEmailVerificationTimeStamp', description='上封验证邮件发送时间', example='1629429213'),
        lastMobileVerificationTimeStamp?: long(name='LastMobileVerificationTimeStamp', description='上条验证短信发送时间', example='1629429213'),
        mobile?: string(name='Mobile', description='用户电话', example='1399999999'),
        name?: string(name='Name', description='联系人名称'),
        position?: string(name='Position', description='职位'),
      }
    ](name='Contacts', description='订阅联系人'),
    description?: string(name='Description', description='订阅项描述'),
    emailStatus?: int32(name='EmailStatus', description='邮件订阅情况', example='1'),
    itemId?: int32(name='ItemId', description='代表资源一级ID的资源属性字段', example='32'),
    itemName?: string(name='ItemName', description='订阅项名称'),
    pmsgStatus?: int32(name='PmsgStatus', description='站内信订阅情况', example='-1'),
    regionId?: string(name='RegionId', description='地域id'),
    smsStatus?: int32(name='SmsStatus', description='短信订阅情况', example='1'),
    ttsStatus?: int32(name='TtsStatus', description='语音短信订阅情况', example='-2'),
    webhookStatus?: int32(name='WebhookStatus', description='回调订阅情况', example='-1'),
    webhooks?: [ 
      {
        name?: string(name='Name', description='名称'),
        serverUrl?: string(name='ServerUrl', description='回调地址', example='https://oapi.dingtalk.com/robot/send?access_token=62ed0b442f4319b2060ee72a3ef833088b6cfc01aad2dd574b4b4eabe907dfff'),
        webhookId?: long(name='WebhookId', description='代表资源一级ID的资源属性字段', example='4539'),
      }
    ](name='Webhooks', description='订阅webhooks'),
  }(name='SubscriptionItemDetail'),
  success?: boolean(name='Success', example='true'),
}

model GetSubscriptionItemDetailResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetSubscriptionItemDetailResponseBody(name='body'),
}

/**
 * @summary 获得订阅项详细描述
 *
 * @param request GetSubscriptionItemDetailRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetSubscriptionItemDetailResponse
 */
async function getSubscriptionItemDetailWithOptions(request: GetSubscriptionItemDetailRequest, runtime: Util.RuntimeOptions): GetSubscriptionItemDetailResponse {
  Util.validateModel(request);
  var query = OpenApiUtil.query(Util.toMap(request));
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetSubscriptionItemDetail',
    version = '2021-07-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'GET',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 获得订阅项详细描述
 *
 * @param request GetSubscriptionItemDetailRequest
 * @return GetSubscriptionItemDetailResponse
 */
async function getSubscriptionItemDetail(request: GetSubscriptionItemDetailRequest): GetSubscriptionItemDetailResponse {
  var runtime = new Util.RuntimeOptions{};
  return getSubscriptionItemDetailWithOptions(request, runtime);
}

model GetWebhookRequest {
  locale?: string(name='Locale', example='zh-cn'),
  webhookId?: long(name='WebhookId', description='This parameter is required.', example='10086'),
}

model GetWebhookResponseBody = {
  code?: string(name='Code', example='200'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId', description='Id of the request'),
  success?: boolean(name='Success', example='true'),
  webhook?: {
    serverUrl?: string(name='ServerUrl', description='回调地址', example='https://oapi.dingtalk.com/robot/send?access_token='),
    webhookId?: long(name='WebhookId', description='代表资源一级ID的资源属性字段', example='10086'),
    webhookName?: string(name='WebhookName', description='名称'),
  }(name='Webhook'),
}

model GetWebhookResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetWebhookResponseBody(name='body'),
}

/**
 * @summary 获取钉钉群机器人
 *
 * @param request GetWebhookRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetWebhookResponse
 */
async function getWebhookWithOptions(request: GetWebhookRequest, runtime: Util.RuntimeOptions): GetWebhookResponse {
  Util.validateModel(request);
  var query = OpenApiUtil.query(Util.toMap(request));
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetWebhook',
    version = '2021-07-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'GET',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 获取钉钉群机器人
 *
 * @param request GetWebhookRequest
 * @return GetWebhookResponse
 */
async function getWebhook(request: GetWebhookRequest): GetWebhookResponse {
  var runtime = new Util.RuntimeOptions{};
  return getWebhookWithOptions(request, runtime);
}

model ListContactsRequest {
  contactId?: long(name='ContactId', example='10086'),
  filter?: string(name='Filter', example='Stopped：&Filter.1.Name=InstanceName&Filter.1.Value.1=i-a123&Filter.1.Value.2=i-b123&Filter.2.Name=Status&Filter.2.Value=Stoppe'),
  locale?: string(name='Locale', example='zh-cn'),
  maxResults?: int32(name='MaxResults', example='100'),
  nextToken?: string(name='NextToken', example='abc-def'),
}

model ListContactsResponseBody = {
  code?: string(name='Code', example='200'),
  contacts?: [ 
    {
      accountUid?: long(name='AccountUid', description='账号UID', example='726322811'),
      contactId?: long(name='ContactId', description='代表资源一级ID的资源属性字段', example='1834830'),
      contactName?: string(name='ContactName', description='联系人名称'),
      email?: string(name='Email', description='联系人电子邮箱', example='turing@addr.cs'),
      isAccount?: boolean(name='IsAccount', description='是否是账号本身', example='false'),
      isObsolete?: boolean(name='IsObsolete', description='是否过期', example='false'),
      isVerifiedEmail?: boolean(name='IsVerifiedEmail', description='电子邮箱是否验证', example='true'),
      isVerifiedMobile?: boolean(name='IsVerifiedMobile', description='电话是否验证', example='false'),
      lastEmailVerificationTimeStamp?: long(name='LastEmailVerificationTimeStamp', description='上封验证邮件发送时间', example='1629369410'),
      lastMobileVerificationTimeStamp?: long(name='LastMobileVerificationTimeStamp', description='上条验证短信发送时间', example='1629369410'),
      mobile?: string(name='Mobile', description='用户电话', example='1399999999'),
      position?: string(name='Position', description='职位'),
    }
  ](name='Contacts'),
  message?: string(name='Message'),
  nextToken?: int32(name='NextToken', example='qwe-erf'),
  requestId?: string(name='RequestId', description='Id of the request', example='4E3E2F84-0A5A-1B3D-AE5F-6593CA019E18'),
  success?: boolean(name='Success', example='true'),
  totalCount?: int32(name='TotalCount', example='10'),
}

model ListContactsResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListContactsResponseBody(name='body'),
}

/**
 * @summary 列举所有联系人
 *
 * @param request ListContactsRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListContactsResponse
 */
async function listContactsWithOptions(request: ListContactsRequest, runtime: Util.RuntimeOptions): ListContactsResponse {
  Util.validateModel(request);
  var query = OpenApiUtil.query(Util.toMap(request));
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListContacts',
    version = '2021-07-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'GET',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 列举所有联系人
 *
 * @param request ListContactsRequest
 * @return ListContactsResponse
 */
async function listContacts(request: ListContactsRequest): ListContactsResponse {
  var runtime = new Util.RuntimeOptions{};
  return listContactsWithOptions(request, runtime);
}

model ListEncryptWebhooksRequest {
  locale?: string(name='Locale', example='zh-cn'),
}

model ListEncryptWebhooksResponseBody = {
  code?: string(name='Code', example='200'),
  data?: [ 
    {
      encryptSecurityToken?: string(name='EncryptSecurityToken', example='izRofgO3nzDo4D1kJjJ+wKKeYsLa4F...'),
      serverUrl?: string(name='ServerUrl', example='https://oapi.dingtalk.com/robot/send?access_token='),
      webhookId?: long(name='WebhookId', example='153369'),
      webhookName?: string(name='WebhookName'),
    }
  ](name='Data'),
  requestId?: string(name='RequestId', description='Id of the request', example='FF1EFA25-9DB3-13E4-9643-5D3AD301C1D'),
  success?: string(name='Success', example='true'),
}

model ListEncryptWebhooksResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListEncryptWebhooksResponseBody(name='body'),
}

/**
 * @summary 列举用户钉钉群机器人（securityToken字段加密）
 *
 * @param request ListEncryptWebhooksRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListEncryptWebhooksResponse
 */
async function listEncryptWebhooksWithOptions(request: ListEncryptWebhooksRequest, runtime: Util.RuntimeOptions): ListEncryptWebhooksResponse {
  Util.validateModel(request);
  var query = OpenApiUtil.query(Util.toMap(request));
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListEncryptWebhooks',
    version = '2021-07-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'GET',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 列举用户钉钉群机器人（securityToken字段加密）
 *
 * @param request ListEncryptWebhooksRequest
 * @return ListEncryptWebhooksResponse
 */
async function listEncryptWebhooks(request: ListEncryptWebhooksRequest): ListEncryptWebhooksResponse {
  var runtime = new Util.RuntimeOptions{};
  return listEncryptWebhooksWithOptions(request, runtime);
}

model ListSubscriptionItemGroupDetailsRequest {
  locale?: string(name='Locale', example='zh-cn'),
}

model ListSubscriptionItemGroupDetailsResponseBody = {
  code?: string(name='Code', example='200'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId', description='Id of the request', example='BA7CC0BA-31E6-18B7-8B78-AA97682099A2'),
  subscriptionItemGroupDetails?: [ 
    {
      description?: string(name='Description'),
      itemDetails?: [ 
        {
          channel?: string(name='Channel', description='属于通道', example='tts'),
          contacts?: [ 
            {
              accountUID?: long(name='AccountUID', description='账号UID', example='12306'),
              contactId?: long(name='ContactId', description='代表资源一级ID的资源属性字段', example='10086'),
              email?: string(name='Email', description='联系人电子邮箱', example='turing@addr.cs'),
              isAccount?: boolean(name='IsAccount', description='是否是账号本身', example='false'),
              isObsolete?: boolean(name='IsObsolete', description='是否过期', example='false'),
              isVerifiedEmail?: boolean(name='IsVerifiedEmail', description='电子邮箱是否验证', example='true'),
              isVerifiedMobile?: boolean(name='IsVerifiedMobile', description='电话是否验证', example='true'),
              lastEmailVerificationTimeStamp?: long(name='LastEmailVerificationTimeStamp', description='上封验证邮件发送时间', example='1629423313'),
              lastMobileVerificationTimeStamp?: long(name='LastMobileVerificationTimeStamp', description='上条验证短信发送时间', example='1629423313'),
              mobile?: string(name='Mobile', description='用户电话', example='1399999999'),
              name?: string(name='Name', description='联系人名称'),
              position?: string(name='Position', description='职位'),
            }
          ](name='Contacts', description='订阅联系人'),
          description?: string(name='Description', description='订阅项描述'),
          emailStatus?: int32(name='EmailStatus', description='邮件订阅情况', example='-1'),
          itemId?: int32(name='ItemId', description='代表资源一级ID的资源属性字段', example='12'),
          itemName?: string(name='ItemName', description='订阅项名称'),
          pmsgStatus?: int32(name='PmsgStatus', description='站内信订阅情况', example='-2'),
          regionId?: string(name='RegionId', description='地域id'),
          smsStatus?: int32(name='SmsStatus', description='短信订阅情况', example='1'),
          ttsStatus?: int32(name='TtsStatus', description='语音短信订阅情况', example='0'),
          webhookStatus?: int32(name='WebhookStatus', description='回调订阅情况', example='0'),
          webhooks?: [ 
            {
              name?: string(name='Name', description='名称'),
              serverUrl?: string(name='ServerUrl', description='回调地址', example='https://oapi.dingtalk.com/robot/send?access_token='),
              webhookId?: long(name='WebhookId', description='代表资源一级ID的资源属性字段', example='10086'),
            }
          ](name='Webhooks', description='订阅webhooks'),
        }
      ](name='ItemDetails'),
      itemGroupId?: int32(name='ItemGroupId', example='12'),
      itemGroupName?: string(name='ItemGroupName'),
    }
  ](name='SubscriptionItemGroupDetails'),
  success?: boolean(name='Success', example='true'),
}

model ListSubscriptionItemGroupDetailsResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListSubscriptionItemGroupDetailsResponseBody(name='body'),
}

/**
 * @summary 获取订阅项和组的详情
 *
 * @param request ListSubscriptionItemGroupDetailsRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListSubscriptionItemGroupDetailsResponse
 */
async function listSubscriptionItemGroupDetailsWithOptions(request: ListSubscriptionItemGroupDetailsRequest, runtime: Util.RuntimeOptions): ListSubscriptionItemGroupDetailsResponse {
  Util.validateModel(request);
  var query = OpenApiUtil.query(Util.toMap(request));
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListSubscriptionItemGroupDetails',
    version = '2021-07-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'GET',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 获取订阅项和组的详情
 *
 * @param request ListSubscriptionItemGroupDetailsRequest
 * @return ListSubscriptionItemGroupDetailsResponse
 */
async function listSubscriptionItemGroupDetails(request: ListSubscriptionItemGroupDetailsRequest): ListSubscriptionItemGroupDetailsResponse {
  var runtime = new Util.RuntimeOptions{};
  return listSubscriptionItemGroupDetailsWithOptions(request, runtime);
}

model ListSubscriptionItemsRequest {
  filter?: string(name='Filter', example='&Filter.1.Name=InstanceName&Filter.1.Value.1=i-a123&Filter.1.Value.2=i-b123&Filter.2.Name=Status&Filter.2.Value=Stopped'),
  itemId?: int32(name='ItemId', example='12'),
  locale?: string(name='Locale', example='zh-cn'),
  maxResults?: int32(name='MaxResults', example='100'),
  nextToken?: string(name='NextToken', example='abc-def'),
}

model ListSubscriptionItemsResponseBody = {
  code?: string(name='Code', example='200'),
  message?: string(name='Message'),
  nextToken?: int32(name='NextToken', example='qwe-ert'),
  requestId?: string(name='RequestId', description='Id of the request', example='CFA1882C-493D-1986-922D-6AF5085C0F91'),
  subscriptionItems?: [ 
    {
      channel?: string(name='Channel', description='属于通道', example='tts'),
      contactIds?: [ long ](name='ContactIds', description='订阅联系人'),
      description?: string(name='Description', description='订阅项描述'),
      emailStatus?: int32(name='EmailStatus', description='邮件订阅情况', example='1'),
      itemId?: int32(name='ItemId', description='代表资源一级ID的资源属性字段', example='32'),
      itemName?: string(name='ItemName', description='订阅项名称'),
      pmsgStatus?: int32(name='PmsgStatus', description='站内信订阅情况', example='0'),
      smsStatus?: int32(name='SmsStatus', description='短信订阅情况', example='-1'),
      ttsStatus?: int32(name='TtsStatus', description='语音短信订阅情况', example='-1'),
      webhookIds?: [ long ](name='WebhookIds', description='订阅webhooks'),
      webhookStatus?: int32(name='WebhookStatus', description='回调订阅情况', example='-2'),
    }
  ](name='SubscriptionItems'),
  success?: boolean(name='Success', example='true'),
  totalCount?: int32(name='TotalCount', example='100'),
}

model ListSubscriptionItemsResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListSubscriptionItemsResponseBody(name='body'),
}

/**
 * @summary 列举用户订阅项
 *
 * @param request ListSubscriptionItemsRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListSubscriptionItemsResponse
 */
async function listSubscriptionItemsWithOptions(request: ListSubscriptionItemsRequest, runtime: Util.RuntimeOptions): ListSubscriptionItemsResponse {
  Util.validateModel(request);
  var query = OpenApiUtil.query(Util.toMap(request));
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListSubscriptionItems',
    version = '2021-07-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'GET',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 列举用户订阅项
 *
 * @param request ListSubscriptionItemsRequest
 * @return ListSubscriptionItemsResponse
 */
async function listSubscriptionItems(request: ListSubscriptionItemsRequest): ListSubscriptionItemsResponse {
  var runtime = new Util.RuntimeOptions{};
  return listSubscriptionItemsWithOptions(request, runtime);
}

model ListWebhooksRequest {
  filter?: string(name='Filter', example='&Filter.1.Name=InstanceName&Filter.1.Value.1=i-a123&Filter.1.Value.2=i-b123&Filter.2.Name=Status&Filter.2.Value=Stopped'),
  locale?: string(name='Locale', example='zh-cn'),
  maxResults?: int32(name='MaxResults', example='100a'),
  nextToken?: string(name='NextToken', example='abc-def'),
  webhookId?: long(name='WebhookId', example='10086'),
}

model ListWebhooksResponseBody = {
  code?: string(name='Code', example='200'),
  message?: string(name='Message'),
  nextToken?: int32(name='NextToken', example='qwe-rty'),
  requestId?: string(name='RequestId', description='Id of the request', example='CFA1882C-493D-1986-922D-6AF5085C0F91'),
  success?: boolean(name='Success', example='true'),
  totalCount?: int32(name='TotalCount', example='10'),
  webhooks?: [ 
    {
      serverUrl?: string(name='ServerUrl', description='回调地址', example='https://oapi.dingtalk.com/robot/send?access_token='),
      webhookId?: long(name='WebhookId', description='代表资源一级ID的资源属性字段', example='10086'),
      webhookName?: string(name='WebhookName', description='名称'),
    }
  ](name='Webhooks'),
}

model ListWebhooksResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListWebhooksResponseBody(name='body'),
}

/**
 * @summary 列举用户钉钉群机器人
 *
 * @param request ListWebhooksRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListWebhooksResponse
 */
async function listWebhooksWithOptions(request: ListWebhooksRequest, runtime: Util.RuntimeOptions): ListWebhooksResponse {
  Util.validateModel(request);
  var query = OpenApiUtil.query(Util.toMap(request));
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListWebhooks',
    version = '2021-07-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'GET',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 列举用户钉钉群机器人
 *
 * @param request ListWebhooksRequest
 * @return ListWebhooksResponse
 */
async function listWebhooks(request: ListWebhooksRequest): ListWebhooksResponse {
  var runtime = new Util.RuntimeOptions{};
  return listWebhooksWithOptions(request, runtime);
}

model SendVerificationMessageRequest {
  contactId?: long(name='ContactId', description='This parameter is required.', example='10086'),
  locale?: string(name='Locale', example='zh-cn'),
  type?: int32(name='Type', description='This parameter is required.', example='1'),
}

model SendVerificationMessageResponseBody = {
  code?: string(name='Code', example='200'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId', description='Id of the request', example='requestId'),
  result?: int32(name='Result', example='10086'),
  success?: boolean(name='Success', example='true'),
}

model SendVerificationMessageResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: SendVerificationMessageResponseBody(name='body'),
}

/**
 * @summary 发送验证信息
 *
 * @param request SendVerificationMessageRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return SendVerificationMessageResponse
 */
async function sendVerificationMessageWithOptions(request: SendVerificationMessageRequest, runtime: Util.RuntimeOptions): SendVerificationMessageResponse {
  Util.validateModel(request);
  var query = OpenApiUtil.query(Util.toMap(request));
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'SendVerificationMessage',
    version = '2021-07-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'GET',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 发送验证信息
 *
 * @param request SendVerificationMessageRequest
 * @return SendVerificationMessageResponse
 */
async function sendVerificationMessage(request: SendVerificationMessageRequest): SendVerificationMessageResponse {
  var runtime = new Util.RuntimeOptions{};
  return sendVerificationMessageWithOptions(request, runtime);
}

model UpdateContactRequest {
  clientToken?: string(name='ClientToken', example='abc-def'),
  contactId?: long(name='ContactId', description='代表资源一级ID的资源属性字段

This parameter is required.', example='10086'),
  contactName?: string(name='ContactName', description='联系人名称

This parameter is required.'),
  email?: string(name='Email', description='联系人电子邮箱

This parameter is required.', example='turing@addr.cs'),
  locale?: string(name='Locale', example='en'),
  mobile?: string(name='Mobile', description='用户电话

This parameter is required.', example='1399999999'),
}

model UpdateContactResponseBody = {
  code?: string(name='Code', example='200'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId', description='Id of the request'),
  result?: boolean(name='Result', example='32'),
  success?: boolean(name='Success', example='true'),
}

model UpdateContactResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: UpdateContactResponseBody(name='body'),
}

/**
 * @summary 更新联系人
 *
 * @param request UpdateContactRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return UpdateContactResponse
 */
async function updateContactWithOptions(request: UpdateContactRequest, runtime: Util.RuntimeOptions): UpdateContactResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.clientToken)) {
    query['ClientToken'] = request.clientToken;
  }
  if (!Util.isUnset(request.locale)) {
    query['Locale'] = request.locale;
  }
  var body : map[string]any = {};
  if (!Util.isUnset(request.contactId)) {
    body['ContactId'] = request.contactId;
  }
  if (!Util.isUnset(request.contactName)) {
    body['ContactName'] = request.contactName;
  }
  if (!Util.isUnset(request.email)) {
    body['Email'] = request.email;
  }
  if (!Util.isUnset(request.mobile)) {
    body['Mobile'] = request.mobile;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'UpdateContact',
    version = '2021-07-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 更新联系人
 *
 * @param request UpdateContactRequest
 * @return UpdateContactResponse
 */
async function updateContact(request: UpdateContactRequest): UpdateContactResponse {
  var runtime = new Util.RuntimeOptions{};
  return updateContactWithOptions(request, runtime);
}

model UpdateSubscriptionItemRequest {
  clientToken?: string(name='ClientToken', example='abc-def'),
  contactIds?: [ long ](name='ContactIds', description='订阅联系人'),
  emailStatus?: int32(name='EmailStatus', description='邮件订阅情况

This parameter is required.'),
  itemId?: int32(name='ItemId', description='This parameter is required.', example='32'),
  locale?: string(name='Locale', example='zh-cn'),
  pmsgStatus?: int32(name='PmsgStatus', description='站内信订阅情况

This parameter is required.'),
  regionId?: string(name='RegionId', description='地域id'),
  smsStatus?: int32(name='SmsStatus', description='短信订阅情况

This parameter is required.'),
  ttsStatus?: int32(name='TtsStatus', description='语音短信订阅情况

This parameter is required.'),
  webhookIds?: [ long ](name='WebhookIds', description='订阅webhooks'),
  webhookStatus?: int32(name='WebhookStatus', description='回调订阅情况

This parameter is required.'),
}

model UpdateSubscriptionItemShrinkRequest {
  clientToken?: string(name='ClientToken', example='abc-def'),
  contactIdsShrink?: string(name='ContactIds', description='订阅联系人'),
  emailStatus?: int32(name='EmailStatus', description='邮件订阅情况

This parameter is required.'),
  itemId?: int32(name='ItemId', description='This parameter is required.', example='32'),
  locale?: string(name='Locale', example='zh-cn'),
  pmsgStatus?: int32(name='PmsgStatus', description='站内信订阅情况

This parameter is required.'),
  regionId?: string(name='RegionId', description='地域id'),
  smsStatus?: int32(name='SmsStatus', description='短信订阅情况

This parameter is required.'),
  ttsStatus?: int32(name='TtsStatus', description='语音短信订阅情况

This parameter is required.'),
  webhookIdsShrink?: string(name='WebhookIds', description='订阅webhooks'),
  webhookStatus?: int32(name='WebhookStatus', description='回调订阅情况

This parameter is required.'),
}

model UpdateSubscriptionItemResponseBody = {
  code?: string(name='Code', example='200'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId', description='Id of the request', example='FF1EFA25-9DB3-13E4-9643-5D3AD301C1D'),
  result?: boolean(name='Result', example='32'),
  success?: boolean(name='Success', example='true'),
}

model UpdateSubscriptionItemResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: UpdateSubscriptionItemResponseBody(name='body'),
}

/**
 * @summary 更新用户订阅项
 *
 * @param tmpReq UpdateSubscriptionItemRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return UpdateSubscriptionItemResponse
 */
async function updateSubscriptionItemWithOptions(tmpReq: UpdateSubscriptionItemRequest, runtime: Util.RuntimeOptions): UpdateSubscriptionItemResponse {
  Util.validateModel(tmpReq);
  var request = new UpdateSubscriptionItemShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!Util.isUnset(tmpReq.contactIds)) {
    request.contactIdsShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.contactIds, 'ContactIds', 'json');
  }
  if (!Util.isUnset(tmpReq.webhookIds)) {
    request.webhookIdsShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.webhookIds, 'WebhookIds', 'json');
  }
  var query = {};
  if (!Util.isUnset(request.clientToken)) {
    query['ClientToken'] = request.clientToken;
  }
  if (!Util.isUnset(request.locale)) {
    query['Locale'] = request.locale;
  }
  var body : map[string]any = {};
  if (!Util.isUnset(request.contactIdsShrink)) {
    body['ContactIds'] = request.contactIdsShrink;
  }
  if (!Util.isUnset(request.emailStatus)) {
    body['EmailStatus'] = request.emailStatus;
  }
  if (!Util.isUnset(request.itemId)) {
    body['ItemId'] = request.itemId;
  }
  if (!Util.isUnset(request.pmsgStatus)) {
    body['PmsgStatus'] = request.pmsgStatus;
  }
  if (!Util.isUnset(request.regionId)) {
    body['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.smsStatus)) {
    body['SmsStatus'] = request.smsStatus;
  }
  if (!Util.isUnset(request.ttsStatus)) {
    body['TtsStatus'] = request.ttsStatus;
  }
  if (!Util.isUnset(request.webhookIdsShrink)) {
    body['WebhookIds'] = request.webhookIdsShrink;
  }
  if (!Util.isUnset(request.webhookStatus)) {
    body['WebhookStatus'] = request.webhookStatus;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'UpdateSubscriptionItem',
    version = '2021-07-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 更新用户订阅项
 *
 * @param request UpdateSubscriptionItemRequest
 * @return UpdateSubscriptionItemResponse
 */
async function updateSubscriptionItem(request: UpdateSubscriptionItemRequest): UpdateSubscriptionItemResponse {
  var runtime = new Util.RuntimeOptions{};
  return updateSubscriptionItemWithOptions(request, runtime);
}

model UpdateWebhookRequest {
  clientToken?: string(name='ClientToken', example='abc-def'),
  locale?: string(name='Locale', example='zh-cn'),
  serverUrl?: string(name='ServerUrl', description='回调地址

This parameter is required.', example='https://oapi.dingtalk.com/robot/send?access_token='),
  webhookId?: long(name='WebhookId', description='代表资源一级ID的资源属性字段

This parameter is required.', example='10086'),
  webhookName?: string(name='WebhookName', description='名称

This parameter is required.'),
}

model UpdateWebhookResponseBody = {
  code?: string(name='Code', example='200'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId', description='Id of the request', example='FF1EFA25-9DB3-13E4-9643-5D3AD301C1D'),
  result?: boolean(name='Result', example='true'),
  success?: boolean(name='Success', example='true'),
}

model UpdateWebhookResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: UpdateWebhookResponseBody(name='body'),
}

/**
 * @summary 更新钉钉群机器人
 *
 * @param request UpdateWebhookRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return UpdateWebhookResponse
 */
async function updateWebhookWithOptions(request: UpdateWebhookRequest, runtime: Util.RuntimeOptions): UpdateWebhookResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.clientToken)) {
    query['ClientToken'] = request.clientToken;
  }
  if (!Util.isUnset(request.locale)) {
    query['Locale'] = request.locale;
  }
  var body : map[string]any = {};
  if (!Util.isUnset(request.serverUrl)) {
    body['ServerUrl'] = request.serverUrl;
  }
  if (!Util.isUnset(request.webhookId)) {
    body['WebhookId'] = request.webhookId;
  }
  if (!Util.isUnset(request.webhookName)) {
    body['WebhookName'] = request.webhookName;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'UpdateWebhook',
    version = '2021-07-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 更新钉钉群机器人
 *
 * @param request UpdateWebhookRequest
 * @return UpdateWebhookResponse
 */
async function updateWebhook(request: UpdateWebhookRequest): UpdateWebhookResponse {
  var runtime = new Util.RuntimeOptions{};
  return updateWebhookWithOptions(request, runtime);
}

